package com.cbd.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cbd.dao.RecordDao;
import com.cbd.pojo.PageBean;
import com.cbd.pojo.Purpose;
import com.cbd.pojo.Record;
import com.cbd.service.PurposeService;
import com.cbd.service.RecordService;
@Service
public class RecordServiceImpl implements RecordService {
	@Resource(name="recordDaoImpl")
	private RecordDao rd;
	@Resource(name="purposeServiceImpl")
	private PurposeService ps;
	@Override
	public void addRecord(int purposeID) {
		// TODO Auto-generated method stub
		Record r = new Record();
		Purpose p  = ps.findPurposeById(purposeID);
		r.setPurpose(p);
		rd.addRecord(r);
	
	}
	@Override
	public PageBean findAllRecord(int ladyId, PageBean page) {
		// TODO Auto-generated method stub
		int num = rd.findRecordNum(ladyId);
		page.setCountPage(num%page.getPageSize()==0?(num/page.getPageSize()):(num/page.getPageSize()+1));
		page = rd.findAllRecord(ladyId, page);
		return page;
	}
	@Override
	public Record findRecordById(int recordID) {
		// TODO Auto-generated method stub
		return rd.findRecordById(recordID);
	}

}
